package ballParadigm;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.border.BevelBorder;
import javax.swing.JTable;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTextField;

public class highScoresTable extends JFrame {

	private JPanel contentPane;
	private JTable table;
	private JTextField textField;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					highScoresTable frame = new highScoresTable();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public highScoresTable() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 600, 420);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);

		JPanel panel = new JPanel();
		panel.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null,
				null));
		panel.setBounds(6, 6, 588, 316);
		contentPane.add(panel);
		panel.setLayout(null);

		table = new JTable();
		table.setBounds(294, 7, 0, 0);
		panel.add(table);
		
		textField = new JTextField();
		textField.setEditable(false);
		textField.setBounds(6, 7, 576, 303);
		panel.add(textField);
		textField.setColumns(10);

		JButton btnClearHighscores = new JButton("Clear Highscores");
		btnClearHighscores.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				saveGame.highScores.clear();
				textField.setText("");
			}
		});
		btnClearHighscores.setBounds(6, 334, 588, 28);
		contentPane.add(btnClearHighscores);

		JButton btnMainMenu = new JButton("Close");
		btnMainMenu.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
			}
		});
		btnMainMenu.setBounds(6, 363, 588, 28);
		contentPane.add(btnMainMenu);
		
		
		for(String myString: saveGame.highScores){
			textField.setText(textField.getText()+"\n"+myString);
		}
	}
}
